#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int N=1e6+10;
//A/b 余t
vector<int>Div(vector<int>&A,int b,int &t)
{
    vector<int>c;
    for(int i=A.size()-1;i>=0;i--)
    {
        t=A[i]+t*10;
        c.push_back(t/b);
        t%=b;
    }
    reverse(c.begin(), c.end());
    while(c.size()>1&&c.back()==0)
        c.pop_back();
    return c;
}
int main()
{
    string a;
    int b,t=0;
    vector<int>A;
    cin>>a>>b;
    for(int i=a.size()-1;i>=0;i--)A.push_back(a[i]-'0');//a 123456 A[654321] 
    vector<int>c=Div(A,b,t);
    for(int i=c.size()-1;i>=0;i--)cout<<c[i];
    cout<<endl<<t<<endl;
    getchar();
    return 0;


}